package bytes;

import java.io.BufferedInputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;

public class BufferedInputStreamTest {

	public static void main(String[] args) throws IOException {
		
		File file = new File( "src/bytes/BufferedInputStreamTest.java" );
		
		InputStream input = new FileInputStream( file );
		
		BufferedInputStream bufferedInput = new BufferedInputStream( input , 1024 );
		
		int n ; // 声明一个变量用来记录实际读取到的有效字节数
		byte[] bytes = new byte[ 100 ]; // 创建一个字节数组当做缓冲区使用(用来保存读取到的有效字节)
		
		while( ( n = bufferedInput.read( bytes ) ) != -1 ) {
			String s = new String( bytes , 0 , n );
			System.out.print( s );
		}
		
		bufferedInput.close();
		input.close();

	}

}
